package cn.micro.tree.bean;

/**
 * 节点包装类，扩展属性（标识计算动态属性）
 */
public class TreeNodeWrapper extends TreeNode {

    protected TreeNodeWrapper(TreeNode treeNode) {
        super(treeNode.getNid(), treeNode.getName(), treeNode.getPid(), treeNode.getSort(), treeNode.getArgs());
    }

    /**
     * 节点左值
     */
    private Integer lft;

    /**
     * 节点右值
     */
    private Integer rgt;

    /**
     * 节点路径名称，逗号分隔
     */
    private String pathName;

    /**
     * 节点路径Id，逗号分隔
     */
    private String pathNid;

    /**
     * 层级
     */
    private Integer level;

    public Integer getLft() {
        return lft;
    }

    public void setLft(Integer lft) {
        this.lft = lft;
    }

    public Integer getRgt() {
        return rgt;
    }

    public void setRgt(Integer rgt) {
        this.rgt = rgt;
    }

    public String getPathName() {
        return pathName;
    }

    public void setPathName(String pathName) {
        this.pathName = pathName;
    }

    public String getPathNid() {
        return pathNid;
    }

    public void setPathNid(String pathNid) {
        this.pathNid = pathNid;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    /**
     * 是否叶子节点
     *
     * @return 是 、 否
     */
    public Boolean isLeaf() {
        return null != this.lft && null != this.rgt && 1 == (this.rgt - this.lft);
    }

    /**
     * 子节点数量
     *
     * @return 数量
     */
    public Integer getCNo() {
        return (null != this.lft && null != this.rgt) ? (this.rgt - this.lft - 1) / 2 : 0;
    }

}
